﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Linq;
namespace PPFinance.Common
{
    public class ThemeCollection
    {
        List<ThemeData> themeCollection { get; set; }

        private ContentControl GetTheme(string assemblyName, string typeName)
        {
            return AssemblyAction.GetObject(assemblyName, typeName);
        }
        public ThemeCollection()
        {
            themeCollection = new List<ThemeData>();
            var colorConvert = new ColorConverter();
            themeCollection.Add(new ThemeData()
            {
                ThemeName = "BubbleCreme",
                Theme = GetTheme("System.Windows.Controls.Theming.BubbleCreme", "System.Windows.Controls.Theming.BubbleCremeTheme")
            });

            //themeCollection.Add(new ThemeData()
            //{
            //    ThemeName = "BureauBlack",
            //    Theme = new BureauBlackTheme(),
            //    SystemBackgroud = Common.UriAction.GetBitmap("Themes/BureauBlack/mainbackground.png"),
            //    TabCloseButtonTheme = new TabCloseButtonTheme() { BackgroundColor = colorConvert.ConvertToColor("#f9f9e4"), LineColor = colorConvert.ConvertToColor("#042271") }
            //});

            //themeCollection.Add(new ThemeData()
            //{
            //    ThemeName = "BureauBlue",
            //    Theme = new BureauBlueTheme(),
            //    SystemBackgroud = Common.UriAction.GetBitmap("Themes/BureauBlue/mainbackground.png"),
            //    TabCloseButtonTheme = new TabCloseButtonTheme() { BackgroundColor = colorConvert.ConvertToColor("#bfdbff"), LineColor = colorConvert.ConvertToColor("#002371") }
            //});

            //themeCollection.Add(new ThemeData()
            //{
            //    ThemeName = "ExpressionDark",
            //    Theme = new ExpressionDarkTheme(),
            //    SystemBackgroud = Common.UriAction.GetBitmap("Themes/ExpressionDark/mainbackground.png"),
            //    TabCloseButtonTheme = new TabCloseButtonTheme() { BackgroundColor = colorConvert.ConvertToColor("#333333"), LineColor = colorConvert.ConvertToColor("#ffffff") }
            //});

            //themeCollection.Add(new ThemeData()
            //{
            //    ThemeName = "ExpressionLight",
            //    Theme = new ExpressionLightTheme(),
            //    SystemBackgroud = Common.UriAction.GetBitmap("Themes/ExpressionLight/mainbackground.png"),
            //    TabCloseButtonTheme = new TabCloseButtonTheme() { BackgroundColor = colorConvert.ConvertToColor("#d6d6d6"), LineColor = colorConvert.ConvertToColor("#000000") }
            //});

            //themeCollection.Add(new ThemeData()
            //{
            //    ThemeName = "RainierOrange",
            //    Theme = new RainierOrangeTheme(),
            //    SystemBackgroud = Common.UriAction.GetBitmap("Themes/RainierOrange/mainbackground.png"),
            //    TabCloseButtonTheme = new TabCloseButtonTheme() { BackgroundColor = colorConvert.ConvertToColor("#ffffff"), LineColor = colorConvert.ConvertToColor("#000000") }
            //});

            //themeCollection.Add(new ThemeData()
            //{
            //    ThemeName = "RainierPurple",
            //    Theme = new RainierPurpleTheme(),
            //    SystemBackgroud = Common.UriAction.GetBitmap("Themes/RainierPurple/mainbackground.png"),
            //    TabCloseButtonTheme = new TabCloseButtonTheme() { BackgroundColor = colorConvert.ConvertToColor("#ffffff"), LineColor = colorConvert.ConvertToColor("#000000") }
            //});

            //themeCollection.Add(new ThemeData()
            //{
            //    ThemeName = "ShinyBlue",
            //    Theme = new ShinyBlueTheme(),
            //    SystemBackgroud = Common.UriAction.GetBitmap("Themes/ShinyBlue/mainbackground.png"),
            //    TabCloseButtonTheme = new TabCloseButtonTheme() { BackgroundColor = colorConvert.ConvertToColor("#ffffff"), LineColor = colorConvert.ConvertToColor("#0459a7") }
            //});

            //themeCollection.Add(new ThemeData()
            //{
            //    ThemeName = "ShinyRed",
            //    Theme = new ShinyRedTheme(),
            //    SystemBackgroud = Common.UriAction.GetBitmap("Themes/ShinyRed/mainbackground.png"),
            //    TabCloseButtonTheme = new TabCloseButtonTheme() { BackgroundColor = colorConvert.ConvertToColor("#a1a1a1"), LineColor = colorConvert.ConvertToColor("#ffffff") }
            //});

            //themeCollection.Add(new ThemeData()
            //{
            //    ThemeName = "System",
            //    Theme = new Theme(),
            //    SystemBackgroud = Common.UriAction.GetBitmap("Themes/System/mainbackground.png"),
            //    TabCloseButtonTheme = new TabCloseButtonTheme() { BackgroundColor = colorConvert.ConvertToColor("#d2dde7"), LineColor = colorConvert.ConvertToColor("#000000") }
            //});
        }

        public ThemeData this[string themeName]
        {
            get
            {
                var themes = themeCollection.Where(p => p.ThemeName.ToUpper().Trim() == themeName.ToUpper().Trim());
                if (themes.Any())
                {
                    return themes.Take(1).Single();
                }
                return themeCollection.Single(p => p.ThemeName == "System");
            }
        }
    }

    public class ThemeData
    {
        public ContentControl Theme { get; set; }

        public string ThemeName { get; set; }

    }
}
